package models

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"video/conf"
)

type Video struct {
	Id      int    `json:"id"`
	Title   string `json:"title"`
	Profile string `json:"profile"`
	Img     string `json:"img"`
	Times   string `json:"times"`
	User    string `json:"user"`
}

var (
	DB  *gorm.DB
	err error
)

func MysqlInit() {
	var Conf = conf.Con
	dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", Conf.User, Conf.Password, Conf.Host, Conf.Port, Conf.Database)
	DB, err = gorm.Open(mysql.Open(dsn))
	if err != nil {
		fmt.Println("连接数据库失败")
		return
	}
	fmt.Println("连接数据库成功")
}

type JsonR struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}
